package lazy2.tool.beangenerator.gui;

import java.io.IOException;
import java.sql.SQLException;
import lazy2.tool.beangenerator.*;

public class BGModel {
	public enum BeanType {JPA, DBXML}
	public void generateBean(BeanType beanType, DBType dbType, String dbAddress, String dbName, String dbPort, String dbUser, String dbPassword, String outputPath, String packageName, String[] tables) throws ClassNotFoundException, SQLException, IOException {
		switch (beanType) {
			case JPA:
				if(tables==null) {
					BeanGenerator.genJpaBean(new JdbcUrl(dbType, dbAddress, dbName), dbUser, dbPassword, outputPath, packageName);
				} else {
					BeanGenerator.genJpaBean(new JdbcUrl(dbType, dbAddress, dbName), dbUser, dbPassword, outputPath, packageName, tables);
				}
				return;
			case DBXML:
				if(tables==null) {
					BeanGenerator.genBean(new JdbcUrl(dbType, dbAddress, dbName), dbUser, dbPassword, outputPath, packageName);
				} else {
					BeanGenerator.genBean(new JdbcUrl(dbType, dbAddress, dbName), dbUser, dbPassword, outputPath, packageName, tables);
				}
				return;
		}
	}
}
